<?php
	
	include('cms.php');
	
	$op = $_POST['op'];
	$idfile = $_POST['idfile'];
	
	if($op == 'rename'){
		
		$newname = $_POST['newname'];
		
		DataLatte::update("UPDATE cmsAttachment SET name = '$newname' WHERE idattachment = '$idfile'");
		
		echo OK;
		
	}
	
	if($op == 'delete'){
		
		$a = DataLatte::oneof('Attachment', "SELECT * FROM cmsAttachment WHERE idattachment = '$idfile'");
		
		DataLatte::update("DELETE FROM cmsAttachment WHERE idattachment = '$idfile'");
		
		@unlink("../cms-data/files/" . $a->path);
		
		Log::add(DETACH, $a->cmsContent_idcontent, $a->name);
		
		echo OK;
		
	}
	
?>